#include "qwtknobhost.h"


#include "../../libs/shared/qhostfactory.h"
#include "../../libs/shared/qpropertyfactory.h"
#include "../../libs/shared/qcommonstruct.h"
#include "../../libs/shared/property/qabstractproperty.h"

QwtKnobHost::QwtKnobHost(QAbstractHost *parent):
    QwtAbstractSliderHost(parent)
{
}

void QwtKnobHost::init_property()
{
    QwtAbstractSliderHost::init_property();

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","knobStyle");
        pro->set_attribute("show_name",tr("Knob Style"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);

        ComboItems   items;
        tagComboItem item;

        item.m_text="Flat";
        item.m_value=QwtKnob::Flat;
        items.append(item);

        item.m_text="Raised";
        item.m_value=QwtKnob::Raised;
        items.append(item);

        item.m_text="Sunken";
        item.m_value=QwtKnob::Sunken;
        items.append(item);

        item.m_text="Styled";
        item.m_value=QwtKnob::Styled;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","knobWidth");
        pro->set_attribute("show_name",tr("Knob Width"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Alignment");
    if(pro!=NULL)
    {
        pro->set_property("name","alignment");
        pro->set_attribute("show_name",tr("Alignment"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","totalAngle");
        pro->set_attribute("show_name",tr("Total Angle"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","markerStyle");
        pro->set_attribute("show_name",tr("Marker Style"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);

        ComboItems   items;
        tagComboItem item;

        item.m_text="NoMarker";
        item.m_value=QwtKnob::NoMarker;
        items.append(item);

        item.m_text="Tick";
        item.m_value=QwtKnob::Tick;
        items.append(item);

        item.m_text="Triangle";
        item.m_value=QwtKnob::Triangle;
        items.append(item);

        item.m_text="Dot";
        item.m_value=QwtKnob::Dot;
        items.append(item);

        item.m_text="Nub";
        item.m_value=QwtKnob::Nub;
        items.append(item);

        item.m_text="Notch";
        item.m_value=QwtKnob::Notch;
        items.append(item);

        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","markerSize");
        pro->set_attribute("show_name",tr("Marker Size"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","borderWidth");
        pro->set_attribute("show_name",tr("Border Width"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    set_property_value("geometry",QRect(0,0,100,100));
}

QString QwtKnobHost::get_show_name()
{
    return tr("QWT Knob");
}

QString QwtKnobHost::get_show_group()
{
    return tr("QWT Widgets");
}

QString QwtKnobHost::get_show_icon()
{
    return ":/images/knob.png";
}

void QwtKnobHost::create_object()
{
    m_object=new QwtKnob;
    m_object->setObjectName("knob");
}

qRegisterHost("qwt.knob",QwtKnobHost,6030)
